package com.example.meet.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.framework.base.BaseFragment;
import com.example.meet.R;
import com.example.meet.adapter.CloudTagAdapter;
import com.moxun.tagcloudlib.view.TagCloudView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created By chentao On 2020/7/24 0:26
 * Describe: 星球
 */
public class StarFragment extends BaseFragment implements View.OnClickListener {

    private ImageView iv_camera;
    private ImageView iv_add;

    private TagCloudView mCloudView;

    private LinearLayout ll_random;
    private LinearLayout ll_soul;
    private LinearLayout ll_fate;
    private LinearLayout ll_love;

    private CloudTagAdapter cloudTagAdapter;
    private List<String> startList = new ArrayList<>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_star, null);
        initView(view);
        return view;
    }

    /**
     * 初始化view
     * @param view
     */
    private void initView(View view) {

        iv_camera = view.findViewById(R.id.iv_camera);
        iv_add = view.findViewById(R.id.iv_add);

        mCloudView = view.findViewById(R.id.mCloudView);

        ll_random = view.findViewById(R.id.ll_random);
        ll_soul = view.findViewById(R.id.ll_soul);
        ll_fate = view.findViewById(R.id.ll_fate);
        ll_love = view.findViewById(R.id.ll_love);

        iv_camera.setOnClickListener(this);
        iv_add.setOnClickListener(this);

        ll_random.setOnClickListener(this);
        ll_soul.setOnClickListener(this);
        ll_fate.setOnClickListener(this);
        ll_love.setOnClickListener(this);

        for (int i=0; i<10; i++){
            startList.add("user-" + i);
        }
        cloudTagAdapter = new CloudTagAdapter(getActivity(), startList);
        mCloudView.setAdapter(cloudTagAdapter);

        //监听点击事件
        mCloudView.setOnTagClickListener(new TagCloudView.OnTagClickListener() {
            @Override
            public void onItemClick(ViewGroup parent, View view, int position) {
                Toast.makeText(getActivity(), "position:" + position, Toast.LENGTH_SHORT).show();
            }
        });

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_camera:
                //扫描
                break;
            case R.id.iv_add:
                //添加好友
                break;
            case R.id.ll_random:
                //随机匹配
                break;
            case R.id.ll_soul:
                //灵魂匹配
                break;
            case R.id.ll_fate:
                //缘分匹配
                break;
            case R.id.ll_love:
                //恋爱匹配
                break;
        }
    }
}
